package com.stefanini.pe.bbva.bp.in.bo.datasource;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class SubReporteSaldoMensualDS  implements JRDataSource{
	
	private List listSaldoMensual = new ArrayList();
    private int indexSaldoMensual = -1;
	
    public SubReporteSaldoMensualDS(List listSaldoMensual) {
    	this.listSaldoMensual = listSaldoMensual;
    }

    public boolean next() throws JRException {
    	indexSaldoMensual++;
        return (indexSaldoMensual < listSaldoMensual.size());
    }
    
    public Object getFieldValue(JRField field) throws JRException {
        Object value = null;
        String fieldName = field.getName();
        HashMap object = (HashMap)listSaldoMensual.get(indexSaldoMensual);
        if ("F_PORC_PROD".equals(fieldName)) {
            value = object.get("F_PORC_PROD")!=null?(Double)object.get("F_PORC_PROD"):null;
        } else if ("F_DESC_PROD".equals(fieldName)) {
            value = object.get("F_DESC_PROD")!=null?(String)object.get("F_DESC_PROD"):"";
        }
        return value;
    }

	public int getIndexSaldoMensual() {
		return indexSaldoMensual;
	}

	public void setIndexSaldoMensual(int indexSaldoMensual) {
		this.indexSaldoMensual = indexSaldoMensual;
	}

	public List getListSaldoMensual() {
		return listSaldoMensual;
	}

	public void setListSaldoMensual(List listSaldoMensual) {
		this.listSaldoMensual = listSaldoMensual;
	}

}
